<template>
  <!-- 灾情勘察 审批 -->
  <div class="EmergencyList">
    <div class="flex location-wrap">
      <span class="white">当前位置：</span>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/EDManagement' }">应急处置</el-breadcrumb-item>
        <el-breadcrumb-item>灾情勘察</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="box">
      <!-- 列表筛选 -->
      <filterTitle @query="query(form)" @reset="reset" :form="form" :formData="formData" labelWidth="140px"
        @node-click="handleSelectTreeTabulation">
        <!-- <el-form slot="filter" class="form" ref="form" :model="form" inline size="small" label-width="140px">
          <el-form-item :label="item.label + '：'" v-for="(item, index) in formData" :key="index" :prop="item.id">
            <LsdForm :compData="item" :form="form" @node-click="handleSelectTreeTabulation(arguments, item)" />
          </el-form-item>
        </el-form> -->
      </filterTitle>
      <!-- 列表表格 -->
      <LsdTable slot="gjxm" @select="handleSelectionChange" @select-all="handleSelectionChange"
        :paginationAtrrs="paginationAtrrs" @pageChange="handleSizeChange" :compRef="table.compRef" ref="gjxm"
        :columns="table.columns" :title="table.title" :actions="table.actions" :tableData="table.tableData"
        :tableAttr="table.tableAttr" :isShowPage="table.isShowPage" :isSelectFlag="table.isSelectFlag"
        :isSequenceFlag="table.isSequenceFlag" @onActionClick="onActionClick" />
    </div>
    <!-- 弹窗信息 -->
    <LsdDialog :dialogConfig="dialogConfig" @handleBtn="handleBtn" @close="close">
      <LsdDialogTitle slot="dialog" :titleConfig="titleConfig" :activeNames="activeNames">
        <DialogForm ref="formComponent" slot="slot1" :formConfig="formConfig" @change="handleChange" />
        <DialogForm ref="formComponent1" slot="slot2" @change="handleChange1" :formConfig="formConfig1"
          @handlePreview="handlePreview" @handleBeforeUpload="handleBeforeUpload" />
        <DialogForm ref="formComponent2" slot="slot3" :formConfig="formConfig2" @getResourcesData="getResourcesData" />
        <!-- <LsdTable ref="WeatherForecasts1" v-if="ranksList !==undefined && ranksList != null  && ranksList.length > 0 " slot="slot3" :paginationAtrrs="WeatherForecasts1.paginationAtrrs" @pageChange="handleSizeChange" :compRef="WeatherForecasts1.compRef" :columns="WeatherForecasts1.columns" :title="WeatherForecasts1.title" :actions="WeatherForecasts1.actions" :tableData="WeatherForecasts1.tableData" :tableAttr="WeatherForecasts1.tableAttr" :isShowPage="WeatherForecasts1.isShowPage" :isSelectFlag="WeatherForecasts1.isSelectFlag" :isSequenceFlag="WeatherForecasts1.isSequenceFlag" @onActionClick="onActionClick" /> -->
        <DialogForm ref="formComponent3" slot="slot4" :formConfig="formConfig3" />
        <DialogForm ref="formComponent4" slot="slot5" :formConfig="formConfig4" />
      </LsdDialogTitle>
    </LsdDialog>
    <!-- 删除确认弹窗 -->
    <el-dialog title="提示" :visible.sync="dialogDelete" width="30%" :before-close="handleClose">
      <span>确定要删除该条数据吗？</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogDelete = false">取 消</el-button>
        <el-button type="primary" @click="dialogDeleteQ">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { zqkcFeedbackList, zqkcFeedbackCheck, zqkcFeedbackDetail, zqkcFeedbackSelete, getSelectedMember } from "@/api/EmergencyDisposal/zqkc.js";
// 响应命令单 列表接口
import { xymldSubmissionList } from "@/api/EmergencyDisposal/xymld.js";
// 公共接口  // BaseMockDepartment
import { getDictByGroup, BaseMockPerson, UploadFile, loadFile, getOrggetSameLevel } from "@/api/common.js";
import { WeatherForecast, WeatherForecasts } from "./components/config";
import { showTime } from "@/lib";
import { flowSubmit } from "@/utils/flow";
export default {
  name: "DisasterSurveyFeedbackCheckList",
  components: {},
  data() {
    return {
      type: 0, // 区分编辑和新增
      multipleSelection: [], // 单选全选
      WeatherForecast: WeatherForecast, // 人员选择后
      WeatherForecasts: WeatherForecasts, // 人员选择前
      xymldSelectData: [], // 响应命令单下拉数据
      valueNameId: {}, // 新增时 选中的响应命令单名称和id
      editId: "",
      deleteId: "",
      dialogDelete: false,
      ranksList: [], // 选中队伍的数据
      // 筛选信息
      formData: [
        {
          elType: "select",
          id: "sourceInfoId",
          label: "响应命令单",
          // dic: "dic_xqlb",
          attrs: {
            value: "",
            size: "small",
            // clearable: true,
            filterable: true,
            "collapse-tags": true,
            clearable: true
          },
          options: []
        },
        {
          elType: "input",
          id: "surveyName",
          label: "任务单名称",
          attrs: {
            value: "",
            size: "small",
            "collapse-tags": true,
            clearable: true
          }
        },
        {
          elType: "input",
          id: "taskContent",
          label: "任务内容",
          attrs: {
            value: "",
            size: "small",
            "collapse-tags": true,
            clearable: true
          }
        },
        {
          elType: "input",
          id: "taskAddress",
          label: "任务地点",
          attrs: {
            value: "",
            size: "small",
            "collapse-tags": true,
            clearable: true
          }
        },
        // {
        //   elType: "cascader",
        //   id: "distributedUnitId",
        //   name: "distributedUnit",
        //   label: "派发单位/部门",
        //   attrs: {
        //     value: "",
        //     size: "small",
        //     clearable: true,
        //     props: {
        //       label: "orgName",
        //       value: "id"
        //     }
        //   },
        //   options: []
        // },
        // {
        //   elType: "cascader",
        //   id: "distributedUnitId",
        //   name: "distributedUnit",
        //   label: "派发单位/部门",
        //   attrs: {
        //     value: "",
        //     size: "small",
        //     // clearable: true,
        //     filterable: true,
        //     "collapse-tags": true,
        //     props: {
        //       label: "orgName",
        //       value: "id",
        //       checkStrictly: true,
        //       emitPath: false
        //     }
        //   },
        //   options: []
        // },
        // {
        //   elType: "cascader",
        //   id: "dutyUnitId",
        //   name: "dutyUnit",
        //   label: "责任单位/部门",
        //   attrs: {
        //     value: "",
        //     size: "small",
        //     // clearable: true,
        //     filterable: true,
        //     "collapse-tags": true,
        //     props: {
        //       label: "orgName",
        //       value: "id",
        //       checkStrictly: true,
        //       emitPath: false
        //     }
        //   },
        //   options: []
        // },
        {
          elType: "selectTree",
          id: "distributedUnitId",
          name: "distributedUnit",
          label: "派发单位/部门",
          attrs: {
            value: "",
            clearable: true,
            "collapse-tags": true
          },
          options: {
            attrs: {
              value: ""
            }
          },
          treeData: {
            attrs: {
              data: []
            },
            props: {
              children: "children",
              label: "orgName",
              value: "id"
            }
          }
        },
        {
          elType: "selectTree",
          id: "dutyUnitId",
          name: "dutyUnit",
          label: "责任单位/部门",
          attrs: {
            value: "",
            clearable: true,
            "collapse-tags": true
          },
          options: {
            attrs: {
              value: ""
            }
          },
          treeData: {
            attrs: {
              data: []
            },
            props: {
              children: "children",
              label: "orgName",
              value: "id"
            }
          }
        },
        {
          elType: "dateTimePicker",
          id: "applyTime",
          label: "计划开始时间",
          attrs: {
            value: "",
            size: "small",
            type: "datetimerange",
            "value-format": "yyyy-MM-dd HH:mm:ss",
            clearable: true
          }
        }
      ],
      // 表格信息
      table: {
        isSelectFlag: false, // 是否展示选择器
        compRef: "gjxm",
        isSequenceFlag: true, // 是否展示序号
        isShowPage: true, // 是否展示分页
        resetFlag: true,
        loading: false,
        title: "勘察任务单列表",
        actions: [
          // {
          //   id: "dialogVisible",
          //   text: "新增",
          //   type: "primary",
          //   btnAttr: { size: "small" }
          // }
          // {
          //   id: "ListAddyp",
          //   text: "研判",
          //   type: "",
          //   btnAttr: { size: "small" }
          // }
        ],
        tableData: [],
        columns: [
          {
            prop: "surveyName",
            label: "任务单名称",
            align: "left",
            "min-width": "200px"
            // render: (h, { row }) => {
            //   return (
            //     <div>
            //       {
            //         <span
            //           style='color:#3561fd;cursor:pointer;text-decoration: underline;'
            //           {...{
            //             on: {
            //               click: () => {
            //                 this.surveyNameClick(row)
            //               }
            //             }
            //           }}
            //         >
            //           {row.surveyName}
            //         </span>
            //       }
            //     </div>
            //   )
            // }
          },
          {
            prop: "taskContent",
            label: "任务内容",
            align: "left",
            "min-width": "180px"
          },
          {
            prop: "taskAddress",
            label: "任务地点",
            align: "left",
            "min-width": "180px"
          },

          {
            prop: "distributedUnit",
            label: "派发单位/部门",
            align: "left",
            "min-width": "150px"
          },
          {
            prop: "dutyUnit",
            label: "责任单位/部门",
            align: "left",
            "min-width": "150px"
          },
          {
            prop: "dutyOfficer",
            label: "责任人",
            align: "center"
          },
          // {
          //   prop: "createTime",
          //   label: "任务发布时间",
          //   align: "center",
          //   "min-width": "170px"
          // },
          // {
          //   prop: "planFinishTime",
          //   label: "要求完成时间",
          //   align: "center",
          //   "min-width": "170px"
          // },
          {
            prop: "startTime",
            label: "计划开始时间",
            align: "center",
            "min-width": "170px"
          },
          {
            prop: "endTime",
            label: "计划结束时间",
            align: "center",
            "min-width": "170px"
          },
          {
            prop: "sourceInfo",
            label: "响应命令单",
            align: "left",
            "min-width": "230px",
            render: (h, { row }) => {
              return (
                <div>
                  {
                    <span
                      style='color:#3561fd;cursor:pointer;text-decoration: underline;'
                      {...{
                        on: {
                          click: () => {
                            this.sourceInfoClick(row);
                          }
                        }
                      }}
                    >
                      {row.sourceInfo}
                    </span>
                  }
                </div>
              );
            }
          },
          {
            prop: "surveyStatusName",
            label: "状态",
            align: "center",
            "min-width": "100px"
          },
          {
            prop: "cz",
            label: "操作",
            align: "center",
            "min-width": "120px",
            render: (h, scope) => {
              let arr = [];
              const userId = JSON.parse(sessionStorage.getItem("account")).id;
              // const spPower = this.common.isHasPower("spr");
              if (scope.row.surveyStatus == 1 && scope.row.nextAssignee && scope.row.nextAssignee.includes(userId)) {
                arr = ["审批"];
              } else {
                arr = [];
              }
              return (
                <div>
                  {
                    arr.map(item => {
                      return (
                        <span style='color:#3561fd;cursor:pointer;margin:0 2px' {...{
                          on: {
                            click: () => {
                              this.actionHandle(item, scope);
                            }
                          }
                        }}>
                          {item}
                        </span>
                      );
                    })
                  }
                </div >
              );
            }
          }
        ],
        // 表格样式
        tableAttr: {
          "max-height": "470px",
          height: "470px",
          stripe: false,
          border: true,
          fit: true,
          "show-header": true,
          "highlight-current-row": true,
          "cell-style": {
            "font-size": "16px"
          },
          "header-cell-style": {
            "text-align": "center",
            "background-color": "#B1C8F9",
            border: "1px solid #ccc",
            "font-size": "16px"
          }
        }
      },
      paginationAtrrs: {
        total: 0,
        "background": true,
        layout: "prev, pager, next",
        "current-page": 1,
        "page-size": 10
      },

      activeNames: ["1", "2", "3", "4", "5"], // 折叠面板默认展开列
      form: {}, // 筛选from
      pageNum: 1,
      pageSize: 10,
      // 弹窗信息
      dialogConfig: {
        title: "勘察任务",
        isShow: false, // 弹窗显示隐藏
        btnList: [
          {
            name: "同意",
            id: "BSubmit", // 事件名
            type: "primary",
            size: "small"
          },
          {
            name: "驳回",
            id: "submitForm",
            size: "small"
          },
          {
            name: "取消",
            id: "Qxiao",
            size: "small"
          }
        ]
      },
      dialogConfig1: {
        title: "人员选择",
        isShow: false, // 弹窗显示隐藏
        btnList: [
          {
            name: "确认",
            id: "BSubmit1", // 事件名
            type: "primary",
            size: "small"
          },
          {
            name: "取消",
            id: "Qxiao1",
            size: "small"
          }
        ]
      },
      // 折叠面板信息
      titleConfig: [
        {
          title: "信息来源",
          name: "1",
          slot: "slot1"
        },
        {
          title: "任务信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "队伍信息",
          name: "3",
          slot: "slot3"
        },
        {
          title: "填报信息",
          name: "4",
          slot: "slot4"
        },
        {
          title: "审批意见",
          name: "5",
          slot: "slot5"
        }
      ],
      // 弹窗表单信息
      formConfig: {
        // disabled: true,
        formData: [
          {
            type: "select",
            label: "响应命令单",
            prop: "sourceInfoId",
            name: "sourceInfo",
            class: "sjgy",
            isDisabled: true,
            lableWidth: "120px",
            option: []
          }
        ]
      },
      // 弹窗表单信息
      formConfig1: {
        // disabled: true,
        formData: [
          {
            type: "input",
            label: "任务单名称",
            prop: "surveyName",
            class: "half",
            isDisabled: true,
            lableWidth: "130px"
          },
          {
            type: "select",
            label: "专业类型",
            prop: "taskType",
            name: "taskTypeName",
            dic: "dic_kclx",
            class: "half",
            isDisabled: true,
            lableWidth: "130px",
            option: []
          },
          {
            type: "select",
            label: "派发单位/部门",
            prop: "distributedUnitId",
            name: "distributedUnit",
            // dic: "dic_yjjb",
            class: "half",
            isDisabled: true,
            lableWidth: "130px",
            option: []
          },
          {
            type: "select",
            label: "责任单位/部门",
            prop: "dutyUnitId",
            name: "dutyUnit",
            // dic: "dic_yjjb",
            class: "half",
            isDisabled: true,
            lableWidth: "130px",
            option: []
          },
          // {
          //   type: "dataPicker",
          //   label: "要求完成时间",
          //   prop: "planFinishTime",
          //   class: "half",
          //   dateType: "datetime",
          //   isDisabled: true,
          //   lableWidth: "130px"
          // },
          {
            type: "dataPicker",
            label: "计划开始时间",
            prop: "startTime",
            class: "half",
            dateType: "datetime",
            isDisabled: true,
            lableWidth: "130px"
          },
          {
            type: "dataPicker",
            label: "计划结束时间",
            prop: "endTime",
            class: "half",
            dateType: "datetime",
            isDisabled: true,
            lableWidth: "130px"
          },
          {
            type: "select",
            label: "责任人",
            prop: "dutyOfficerId",
            name: "dutyOfficer",
            // dic: "dic_yjjb",
            class: "half",
            isDisabled: true,
            lableWidth: "130px",
            option: []
          },
          {
            type: "input",
            label: "任务地点",
            prop: "taskAddress",
            // class: "sjgy",
            class: "half",
            isDisabled: true,
            lableWidth: "130px"
          },
          {
            type: "input",
            label: "任务内容",
            prop: "taskContent",
            class: "sjgy",
            isDisabled: true,
            lableWidth: "130px"
          },
          // {
          //   type: "upload",
          //   label: "附件",
          //   action: "",
          //   prop: "ztqks",
          //   // fileList
          //   isDisabled: true,
          //   lableWidth: "130px"
          // },
          {
            type: "upload",
            label: "附件",
            prop: "ztqks",
            action: "#",
            limit: 1,
            isDisabled: true,
            // httpRequest: () => { },
            lableWidth: "140px"
          }
        ]
      },
      // 弹窗表单信息
      formConfig2: {
        // disabled: true,
        formData: [
          {
            type: "btnInput",
            label: "选择队伍",
            value: "请选择",
            prop: "emergencyEvent",
            // class: "sjgy",
            class: "half",
            isDisabled: true,
            hidden: false,
            lableWidth: "200px"
          },
          {
            type: "input",
            label: "需求人数",
            prop: "needNumberOfPeople",
            // class: "sjgy",
            class: "half",
            isDisabled: true,
            lableWidth: "140px"
          }
        ]
      },
      // 填报信息
      formConfig3: {
        // disabled: true,
        formData: [
          {
            type: "input",
            label: "填报人",
            prop: "creator",
            class: "third",
            isDisabled: true,
            lableWidth: "130px"
          },
          {
            type: "input",
            label: "单位及部门",
            class: "third",
            prop: "creatorUnit",
            isDisabled: true,
            lableWidth: "130px"
          },
          {
            type: "input",
            label: "填报时间",
            class: "third",
            prop: "createTime",
            isDisabled: true,
            lableWidth: "130px"
          }
        ]
      },
      // 审核信息
      formConfig4: {
        formData: [
          {
            type: "input",
            label: "审核意见",
            prop: "approvalOpinion",
            class: "sjgy",
            lableWidth: "130px"
          },
          {
            type: "input",
            label: "审核人",
            prop: "creator",
            isDisabled: true,
            class: "third",
            lableWidth: "130px"
          },
          {
            type: "input",
            label: "单位及部门",
            class: "third",
            isDisabled: true,
            prop: "approvalDept",
            lableWidth: "130px"
          },
          {
            type: "input",
            label: "审核时间",
            class: "third",
            isDisabled: true,
            prop: "createTime",
            lableWidth: "130px"
          }
        ]
      },
      // 选择队伍后回显 tab表格
      WeatherForecasts1: {
        isSelectFlag: true, // 是否展示选择器
        compRef: "gjxm",
        isSequenceFlag: true, // 是否展示序号
        isShowPage: true, // 是否展示分页
        resetFlag: true,
        loading: false,
        title: "",
        actions: [
        ],
        tableData: [],
        columns: [
          {
            prop: "unit",
            label: "所属单位",
            align: "center",
            "min-width": "230px"
          },
          {
            prop: "member",
            label: "姓名",
            align: "center",
            "min-width": "200px"
          },
          {
            prop: "contact",
            label: "联系方式",
            align: "center"
          },
          {
            prop: "type",
            label: "人员类型",
            align: "center"
          },

          {
            prop: "major",
            label: "人员专业",
            align: "center"
          },
          {
            prop: "ability",
            label: "特种作业能力",
            align: "center"
          },
          {
            prop: "checkInDate",
            label: "入岗时间",
            align: "center"
          }
        ],
        // 表格样式
        tableAttr: {
          "max-height": "300px",
          // height: "470px",
          stripe: false,
          border: true,
          fit: true,
          "show-header": true,
          "highlight-current-row": true,
          "cell-style": {
            "font-size": "16px"
          },
          "header-cell-style": {
            "text-align": "center",
            "background-color": "#B1C8F9",
            border: "1px solid #ccc",
            "font-size": "16px"
          }
        },
        paginationAtrrs: {
          total: 0,
          "background": true,
          layout: "prev, pager, next",
          "current-page": 1,
          "page-size": 10
        }
      },
      FilledBy: {}

    };
  },
  watch: {
  },
  mounted() {
    const FilledBy = {
      creator: JSON.parse(sessionStorage.getItem("account")).realName,
      creatorId: JSON.parse(sessionStorage.getItem("account")).id,
      deptId: JSON.parse(sessionStorage.getItem("org")).orgCode,
      unitDeptName: JSON.parse(sessionStorage.getItem("org")).orgName,
      // createTime: new Date().toLocaleString(),
      createTime: showTime(new Date()),
      approvalUserId: JSON.parse(sessionStorage.getItem("account")).id,
      approvalUser: JSON.parse(sessionStorage.getItem("account")).realName,
      pprovalDeptId: JSON.parse(sessionStorage.getItem("org")).orgCode,
      // approvalDept: JSON.parse(sessionStorage.getItem("org")).orgName,
      approvalDept: sessionStorage.getItem("dwbmName"),
      approvalTime: new Date().toLocaleString()
    };
    this.FilledBy = FilledBy;
    this.list();
    this.getFormInput();
    this.getInputVal();
  },
  methods: {
    // 工作流审批
    gzlAudit(type, variable) {
      const data = {
        bizKey: this.editId,
        flowKey: "emergency_survey_001",
        taskId: "task2",
        callbackUrl: "/emergency/emergencySurvey/handleFlow",
        idea: type === 3 ? "1" : "0",
        variable,
        ideaMsg: this.$refs.formComponent4.form.approvalOpinion ? this.$refs.formComponent4.form.approvalOpinion : type === 3 ? "同意" : "驳回"
      };
      const successCallBack = () => {
        this.$message({
          message: `${type === 3 ? "审核" : "驳回"}成功`,
          type: "success"
        });
        this.dialogConfig.isShow = false;
        this.list();
      };
      flowSubmit(data, successCallBack, "审核");
    },
    handleupdata(val) {
      console.log(val);
    },
    //  响应命令单选择的数据
    handleChange(val) {
      // console.log(val)
      // 获取选中的 名称和id
      this.formConfig.formData[0].option.forEach(i => {
        if (i.value === val) {
          // console.log(i)
          this.valueNameId = i;
        }
      });

    },
    handleChange1(val) {
      console.log(val);
    },
    // 弹窗按钮点击事件 对应id绑定事件
    handleBtn(item) {
      this[item.id]();
    },
    handleBtn1(item) {
      this[item.id]();
    },
    // 重置
    reset() {
      this.form = this.$options.data().form;
      this.pageNum = 1;
      this.$refs.gjxm.paginationAtrrsInner["current-page"] = 1;
      this.list();
    },
    // 列表
    async list() {
      const parmas = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        surveyStatus: 1
      };
      const res = await zqkcFeedbackList(parmas);
      this.table.tableData = res.data;
      this.paginationAtrrs.total = res.total;
    },
    // 检索
    async query(val) {
      const parmas = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        surveyStatus: 1, // 待审核
        surveyName: this.form.surveyName,
        taskContent: this.form.taskContent,
        taskAddress: this.form.taskAddress,
        sourceInfoId: this.form.sourceInfoId,
        // distributedUnitId: val.distributedUnitId && val.distributedUnitId[val.distributedUnitId.length - 1],
        // dutyUnitId: val.dutyUnitId && val.dutyUnitId[val.dutyUnitId.length - 1],
        dutyUnitId: val.dutyUnit,
        distributedUnitId: val.distributedUnit,
        // taskPublishTimeStart: val.applyTime ? val.applyTime[0] : "", // 开始时间
        // taskPublishTimeEnd: val.applyTime ? val.applyTime[1] : "" // 结束时间
        startTime: val.applyTime ? val.applyTime[0] : "", // 计划开始时间
        endTime: val.applyTime ? val.applyTime[1] : "" // 计划结束时间

      };
      const res = await zqkcFeedbackList(parmas);
      this.table.tableData = res.data;
      this.paginationAtrrs.total = res.total;
    },
    // 驳回
    async submitForm() {
      const parmas = {
        id: this.editId, // 编辑 / 详情 id
        approvalOpinion: this.$refs.formComponent4.form.approvalOpinion, // 审批意见
        approveSign: "reject", // 驳回

        approvaUser: this.$refs.formComponent4.form.approvalUser, // 审批人
        // approveUserId: this.$refs.formComponent4.form.approvalUserId, // 审批人id
        approveDeptId: this.FilledBy.deptId, // 审批部门id
        approveDept: this.$refs.formComponent4.form.approvalDept, // 审批部门
        // approveDeptId: this.$refs.formComponent4.form.approvalUser, //审批部门id
        approveTime: this.$refs.formComponent4.form.approvalTime, //
        creator: this.$refs.formComponent3.form.creator, // 创建人
        createId: this.$refs.formComponent3.form.creatorId, // 创建人id
        creatorDeptId: this.$refs.formComponent3.form.deptId, // 创建人部门id
        creatorDeptName: this.$refs.formComponent3.form.unitDeptName // 创建人部门名称
      };
      // console.log(parmas)
      const res = await zqkcFeedbackCheck(parmas);
      // console.log(res)
      if (res) {
        this.gzlAudit(4, parmas);
      }
    },
    // 同意
    async BSubmit() {
      const parmas = {
        id: this.editId, // 编辑 / 详情 id
        approvalOpinion: this.$refs.formComponent4.form.approvalOpinion, // 审批意见
        approveSign: "pass", // 同意
        approvaUser: this.$refs.formComponent4.form.approvalUser, // 审批人
        // approveUserId: this.$refs.formComponent4.form.approvalUserId, // 审批人id
        approveDeptId: this.FilledBy.deptId, // 审批部门id
        approveDept: this.$refs.formComponent4.form.approvalDept, // 审批部门
        surveyName: this.$refs.formComponent2.form.surveyName,
        // approveDeptId: this.$refs.formComponent4.form.approvalUser, //审批部门id
        approveTime: this.$refs.formComponent4.form.approvalTime, //
        creator: this.$refs.formComponent3.form.creator, // 创建人
        createId: this.$refs.formComponent3.form.creatorId, // 创建人id
        creatorDeptId: this.$refs.formComponent3.form.deptId, // 创建人部门id
        creatorDeptName: this.$refs.formComponent3.form.unitDeptName // 创建人部门名称

      };
      console.log(parmas);
      const res = await zqkcFeedbackCheck(parmas);
      // console.log(res)
      if (res) {
        this.gzlAudit(3, parmas);
        // this.$message({
        //   message: "审批成功",
        //   type: "success"
        // });
        // this.dialogConfig.isShow = false;
        // this.list();
      }
    },
    // 审核弹窗取消
    Qxiao() {
      this.formConfig2.formData.map(item1 => {
        item1.hidden = false;
      });
      this.$refs.formComponent4.form.approvalOpinion = "";
      this.$refs.formComponent.form = this.$refs.formComponent.$options.data().form;
      this.$refs.formComponent1.form = this.$refs.formComponent1.$options.data().form;
      this.$refs.formComponent2.form = this.$refs.formComponent2.$options.data().form;
      this.$refs.formComponent3.form = this.$refs.formComponent3.$options.data().form;
      this.$refs.formComponent4.form = this.$refs.formComponent4.$options.data().form;
      this.$nextTick(() => {
        this.$refs.formComponent.$refs.formInlines.clearValidate();
        this.$refs.formComponent1.$refs.formInlines.clearValidate();
        this.$refs.formComponent2.$refs.formInlines.clearValidate();
        this.$refs.formComponent3.$refs.formInlines.clearValidate();
        this.$refs.formComponent4.$refs.formInlines.clearValidate();

      });
    },
    // 取消
    Qxiao1() {
      this.dialogConfig1.isShow = false;
    },
    // 审核 弹窗关闭图标
    close() {
      this.formConfig2.formData.map(item1 => {
        item1.hidden = false;
      });
      this.$refs.formComponent4.form.approvalOpinion = "";
      this.$refs.formComponent.form = this.$refs.formComponent.$options.data().form;
      this.$refs.formComponent1.form = this.$refs.formComponent1.$options.data().form;
      this.$refs.formComponent2.form = this.$refs.formComponent2.$options.data().form;
      this.$refs.formComponent3.form = this.$refs.formComponent3.$options.data().form;
      this.$refs.formComponent4.form = this.$refs.formComponent4.$options.data().form;
      this.$nextTick(() => {
        this.$refs.formComponent.$refs.formInlines.clearValidate();
        this.$refs.formComponent1.$refs.formInlines.clearValidate();
        this.$refs.formComponent2.$refs.formInlines.clearValidate();
        this.$refs.formComponent3.$refs.formInlines.clearValidate();
        this.$refs.formComponent4.$refs.formInlines.clearValidate();

      });
      this.dialogConfig.isShow = false;
    },
    // 弹窗关闭图标
    close1() {
      this.dialogConfig1.isShow = false;
    },
    // 获取表单下拉框
    getFormInput() {
      // 筛选
      this.formData.forEach((item) => {
        if (item.elType === "selectTree") {
          getOrggetSameLevel({ orgId: JSON.parse(sessionStorage.getItem("org")).orgId }).then(res => {
            this.$nextTick(() => {
              if (item.label === "派发单位/部门") {
                this.$set(this.formData[4].treeData.attrs, "data", res);
              }
            });
          });
          getOrggetSameLevel({ orgId: JSON.parse(sessionStorage.getItem("org")).orgId }).then(res => {
            this.$nextTick(() => {
              if (item.label === "责任单位/部门") {
                this.$set(this.formData[5].treeData.attrs, "data", res);
              }
            });
          });
        }
      });
    },
    // 获取下拉框数据
    getInputVal() {
      const parmas = {
        pageNum: this.pageNum,
        pageSize: this.pageSize
      };
      this.formData.map(item => {
        if (item.label === "响应命令单") {
          xymldSubmissionList(parmas).then(res => {
            const option = res.data.map((item) => {
              // console.log(item)
              var sourceInfo = item.responseName;
              return {
                label: sourceInfo,
                value: item.id
              };
            });
            item.options = option;

          });
        }
      });
      this.formData.forEach((item) => {
        if (item.dic) {
          getDictByGroup({ groupCode: item.dic }).then(res => {
            const option = res.map((item) => {
              return {
                label: item.dicName,
                value: Number(item.dicCode)
              };
            });
            item.options = option;
          });
        }
      });
      this.formConfig.formData.forEach((item) => {
        if (item.dic) {
          getDictByGroup({ groupCode: item.dic }).then(res => {
            const option = res.map((item) => {
              return {
                label: item.dicName,
                value: Number(item.dicCode)
              };
            });
            item.option = option;
          });
        }
      });
      this.formConfig1.formData.forEach((item) => {
        if (item.dic) {
          getDictByGroup({ groupCode: item.dic }).then(res => {
            const option = res.map((item) => {
              return {
                label: item.dicName,
                value: Number(item.dicCode)
              };
            });
            item.option = option;
          });
        }
      });
    },

    // 人员选择
    getResourcesData() {
      console.log("选择");
      this.dialogConfig1.isShow = true;
    },
    // 抛出列表按钮
    onActionClick(item, index) {
      this[item.id](); // 调用按钮对应方法
    },

    // 新增
    dialogVisible() {
      this.dialogConfig.isShow = true;
      this.$nextTick(() => {
        this.$refs.formComponent3.form = this.FilledBy;
        console.log(this.$refs.formComponent3.form);
        this.$refs.formComponent4.form = this.FilledBy;
        console.log(this.$refs.formComponent4.form, "审批人");
      });
      const parmas = {
        pageNum: this.pageNum,
        pageSize: this.pageSize
        // surveyStatus: 0
      };
      this.formConfig.formData.map(item => {
        if (item.label === "响应命令单") {
          xymldSubmissionList(parmas).then(res => {
            const option = res.data.map((item) => {
              // console.log(item)
              var sourceInfo = item.responseName;
              return {
                label: sourceInfo,
                value: item.id
              };
            });
            item.option = option;
          });
        }
      });
      // 责任人
      this.formConfig1.formData.map(item => {
        if (item.label === "责任人") {
          BaseMockPerson(parmas).then(res => {
            const option = res.map((item) => {
              // console.log(item);
              return {
                label: `${item.realName}`,
                value: item.id,
                ...item
              };
            });
            item.option = option;
          });
        }
      });

    },
    // 响应命令单名称
    sourceInfoClick(val) {
      this.$router.push({
        name: "EmergencyResponseinfo",
        query: { id: val.sourceInfoId }
      });
    },
    // 任务单名称
    surveyNameClick(val) {
      if (val.taskType === "1") {
        this.$router.push({
          name: "StatisticalDetails", // 基干勘察详情
          query: { id: val.id }
        });
      } else if (val.taskType === "2") {
        this.$router.push({
          name: "TransmissionDetails", // 输电
          query: { id: val.id }
        });
      } else if (val.taskType === "3") {
        this.$router.push({
          name: "PowerTransformationDetails", // 变电
          query: { id: val.id }
        });
      } else if (val.taskType === "4") {
        this.$router.push({
          name: "PowerDistributionDetails", // 配电
          query: { id: val.id }
        });
      } else if (val.taskType === "5") {
        this.$router.push({
          name: "MarketingDetails", // 营销
          query: { id: val.id }
        });
      }
    },
    // 选择器
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 列表表格按钮事件
    actionHandle(item, scope) {
      if (item === "审批") {

        this.HanEdit(scope.row);
      }
    },
    // 审批
    HanEdit(id) {
      // console.log(id);
      this.dialogVisible();
      this.editId = id.id;
      this.dialogConfig.isShow = true;
      this.formConfig1.formData[8].type = "input";
      this.formConfig1.formData[8].isDisabled = true;
      this.WeatherForecasts1.isSelectFlag = false; // 审批时去掉选择器 by hepeng 2022年12月16日10:14:33
      zqkcFeedbackDetail({ id: id.id }).then(res => {
        if (res.surveyTeamName === "" || res.surveyTeamName === null) {
          this.duiwuName = "";
        } else {
          this.duiwuName = res.surveyTeamName || "";// 将详情中队伍名称存起来
          this.duiwuId = id.surveyTeamId || ""; // 将详情中队伍id存起来
        }
        // console.log(this.duiwuName);
        this.formConfig2.formData.map(item1 => {
          if (this.duiwuName !== "") {
            // item1.value = this.duiwuName;
            item1.value = res.surveyTeamName;
          } else {
            item1.hidden = true;
          }
        });
        const parmas = {
          pageNum: 1,
          pageSize: 10,
          surveyId: id.id
          // occupation: 0
        };
        setTimeout(() => {
          if (res.surveyTeam !== null || res.surveyTeam !== "") {
            // duiyuanDataList(parmas).then(item => {
            getSelectedMember(parmas).then(item => {
              console.log(item);
              this.WeatherForecasts1.tableData = item.data;
              this.WeatherForecasts1.paginationAtrrs.total = item.total;
              this.ranksList = item.data;
              const ids = this.WeatherForecasts1.tableData.map(i => i.id);
              this.$set(this.WeatherForecasts1.tableData, "smallId", ids);
            });
          }
        });
        this.type = 1;
        this.$refs.formComponent.form = res;
        this.$refs.formComponent1.form = res;
        this.$refs.formComponent2.form = res;
        this.$refs.formComponent3.form = res; // 填报人
        // this.$refs.formComponent4.form = res // 审批意见
        const list = res.attachInfo;
        const newList = [];
        list.forEach(item => {
          newList.push({
            name: item.attachName,
            attachId: item.attachId
          });
        });
        // const attachInfo = res.attachInfo.map(item => {
        //   return item.attachName;
        // });
        this.$set(this.$refs.formComponent1, "fileList", newList);
        // this.$set(this.$refs.formComponent1.form, "ztqks", attachInfo.join("、"));
        this.ranksList = res.surveyTeam;
        this.$set(this.$refs.formComponent1.form, "yxTime", [res.effectStartTime, res.effectEndTime]);
      });
    },
    async dialogDeleteQ() {
      console.log("删除");
      const res = await zqkcFeedbackSelete({
        id: this.deleteId
      });
      if (res) {
        this.$message({
          message: "删除成功",
          type: "success"
        });
        this.dialogDelete = false;
        this.list();
      }
    },
    handleClose(done) {
      // console.log(done);
    },
    // 删除
    async detailForm(id) {
      this.dialogDelete = true;
      this.deleteId = id.id;
    },
    // 列表组织机构查询
    handleSelectTreeTabulation(arg, item) {
      if (item.id === "distributedUnitId") {
        this.$set(this.form, "distributedUnit", arg[0].id);
        this.$set(this.form, "distributedUnitId", arg[0].orgName);
      } else if (item.id === "dutyUnitId") {
        this.$set(this.form, "dutyUnit", arg[0].id);
        this.$set(this.form, "dutyUnitId", arg[0].orgName);
      }
    },
    // 分页
    handleSizeChange(val) {
      this.pageNum = val["current-page"];
      this.pageSize = val["page-size"];
      this.list();
    },
    handleBeforeUpload(file) {
      const parmas = {
        file: file,
        directoryId: 0,
        isNew: true,
        moduleName: "EmergencyEvent"
      };
      UploadFile(this.common.convertFormData(parmas)).then(data => {
        this.$nextTick(() => {
          this.$refs.formComponent1.fileList.push({ name: data.fileName, attachId: data.id });
        });
      });
    },
    // 下载
    handlePreview(file) {
      console.log(file, "file");
      loadFile({ id: file.attachId }).then(data => {
        window.open(data);
      });
    }
  }
};
</script>

<style scoped lang="less">
// @import "../../../assets/style/ComponentStyle.less";
@import "../../../assets/style/common.less";
@import "../../../assets/style/ComponentStyle.less";
@import "../../../assets/style/pop-upNotification.less";

:deep(.TeamChoose) {
  width: auto !important;
}

:deep(.el-breadcrumb__inner.is-link) {
  font-weight: 100;
  color: #fff;
}

.EmergencyList :deep(.el-breadcrumb__item:last-child .el-breadcrumb__inner) {
  color: #3270ff;
}

.box {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-top: 15px;
  background-color: #fff;
  border-radius: 4px;
  padding: 10px;
  box-sizing: border-box;
}
</style>
